<template>
    <div>
         <div class="div">
            <el-input
            placeholder="请输入运单号"
            v-model="form.waybill_number"
            clearable>
            </el-input>

            <br/><br/>

            <el-select v-model="form.client_id" size='medium' placeholder="请选择客户" style="width: 400px;" >
                <el-option
                v-for="item in options"
                :key="item.id"
                :label="item.address"
                :value="item.id">
                </el-option>
            </el-select>
         </div>

        <div class="div2">
            <el-row>
                <el-button type="success"  size='medium' @click="post_waybill">提交</el-button>
            </el-row>
        </div>  
    </div>
</template>



<script>
import { client_get,waybill_post } from '../../api/api.js'
export default {
    inject:['reload'],
    data(){
        return{
            // 发送的数据
            form:{
               waybill_number:'',
               client_id:'',
               company_id:'',
            },
            // 客户信息
            options: [],
  
        }
    },
    mounted() {
        // 获取所属公司
        this.form.company_id = localStorage.getItem('com_id')
        //客户请求
        this.get_client()
    },
    methods: {
        // 获取客户
        get_client(){
            client_get({com_id:this.form.company_id}).then(res=>{
                console.log(res)
                this.options = res.data
            })
        },
        // 添加运单
        post_waybill(){
            waybill_post(this.form).then(res=>{
                console.log(res)
                if(res.code==200){
                    this.$message(res.message)
                    this.reload()  
                }
            })
        },
    },
}
</script>


<style >
.div{
    width: 400px;
    padding: 200px 0px 0px 550px;
}
.div2{
    padding: 20px 0px 0px 700px;
}
</style>